#ifndef CONNECTIONINTERFACE_H
#define CONNECTIONINTERFACE_H

#include <serverconnection.h>
#include <QVector>
#include <QStringList>

class ConnectionInterface : public QObject
{
    Q_OBJECT

public:
    ConnectionInterface(); // constructor
    ~ConnectionInterface(); // deconstructor

    // Creates a new connection and returns true if connection was made, false if not
    bool newConnection(QString name, QString host, int port, QString authName, QString password, QString filterString, bool writeEnabled);
private:
    int _numConnections; // The total number of connections QVector::size()
    QVector<ServerConnection*> _connections; // QVector containing pointers to connection objects
public:
    void connectToServer(int connectionID); // Connect to the server represented by connection connectionID
    void disconnectFromServer(int connectionID); // disconnect from the server represented by connection connectionID

    // Change any of the parameters of the connection represented by connection connectionID
    void changeParameters(QString name, QString host, int port, QString authName, QString password, QString filterString, int connectionID);
    void writeToSocket(QString aprsPacket); // Write the packet aprsPacket to connection to server represented by connection connectionID
    bool isConnected(int connectionID); // Tests if the connection represented by connection connectionID is connected
    QString getName(int connectionID); // Returns the name given to this connection
    QString getHostName(int connectionID); // Returns the hostname of the server that this object connects to
    int getPortNumber(int connectionID); // Returns the port number used to connect
    QString getUserName(int connectionID); // Returns the username used to log onto server
    QString getPassword(int connectionID); // Returns the password associated with the username used to log onto the server
    QString getFilterString(int connectionID); // Returns the filter string that was set for this server
    void deleteConnection(int connectionID);
    QStringList getConnectionNames();
    void removeConnection(int connectionID);
    bool isTransmitEnabled(int connectionID);

public slots:
    void getData(QString data); // Slot that catches all emitted signals
signals:
    void newData(QString); // emitted containing new packet
};

#endif // CONNECTIONINTERFACE_H
